import Taro from '@tarojs/taro';
const globalData = {
  userInfo:{},
  userToken:null,
  userRole:1, //用户角色 默认1 是 车主  2 是司机
  orderInfo:{
    startAddress:{
      address:"",
      latitude:"",
      longitude:"",
    },
    endAddress:{
      address:"",
      latitude:"",
      longitude:"",
    },
    start_time:"",
    is_dang:"",
    car_id:"",
  },
  navHeight:"",
}
export function setGlobalData (key, val) {
  globalData[key] = val
}
export function getGlobalData (key) {
  return globalData[key]
}
//高度数据同步方法
export function getToken () {
  globalData.userToken = Taro.getStorageSync('userToken') || null;
  return globalData.userToken
}
export function setToken (key) {
  if (key == '') {
    Taro.removeStorageSync('userToken');
    globalData.userToken = null;
  }else{
    Taro.setStorageSync('userToken',key);
    globalData.userToken = key;
  }
}
export function getRole () {
  globalData.userToken = Taro.getStorageSync('userRole') || null;
  return globalData.userToken
}
export function setRole (key) {
  if (key == '') {
    Taro.removeStorageSync('userRole');
    globalData.userToken = null;
  }else{
    Taro.setStorageSync('userRole',key);
    globalData.userToken = key;
  }
}